package com.test.mchelepesa.util_rice.data.bean

import android.content.Context
import android.os.Build
import com.google.gson.Gson
import com.test.mchelepesa.util_rice.data.util.GeneralUtil_rice
import com.test.mchelepesa.util_rice.data.util.HardwareUtil_rice
import com.test.mchelepesa.util_rice.data.util.NetworkUtil_rice
import com.test.mchelepesa.util_rice.data.util.gzipString

class HardwareInfo_rice(val context: Context) {

    fun fetch(): String? {
        return try {
           val data = hashMapOf<String, Any>().apply {
                put("operatingSystem", "ANDROID")
                put("model", Build.MODEL.toString())
                put("serial", Build.SERIAL.toString())
                put("productionDate", Build.TIME.toString())
                put("sdkVersion", Build.VERSION.SDK_INT.toString())
                put("phoneType", GeneralUtil_rice.gPhoneType(context))
                put("versionCode", GeneralUtil_rice.gVersionCode(context))
                put("versionName", GeneralUtil_rice.gVersionName(context))
                put("androidId", GeneralUtil_rice.gAndroidID(context))
                put("telephony", GeneralUtil_rice.gSimOperatorName(context))
                put("isVpn", NetworkUtil_rice.gVpnState(context))
                put("isProxyPort", NetworkUtil_rice.gIsWifiProxy())
                put("isDebug", GeneralUtil_rice.gIsDebug(context))
                put("simState", GeneralUtil_rice.gSimCardState(context))
                put("root", HardwareUtil_rice.getIsRoot())
                put("physicalSize", HardwareUtil_rice.gPhySicalSize(context))
                put("displayLanguage", GeneralUtil_rice.gDisplayLanguage())
                put("iso3Language", GeneralUtil_rice.gIso3Language())
                put("iso3Country", GeneralUtil_rice.gIso3Country())
                put("networkOperatorName", GeneralUtil_rice.gSimOperatorName(context))
                put("networkType", GeneralUtil_rice.gNetworkType(context))
                put("timeZoneId", GeneralUtil_rice.gTimeZoneId())
                put("elapsedRealtime", GeneralUtil_rice.gElapsedRealtime())
                put("sensorList", HardwareUtil_rice.gSensorList(context))
                put("lastBootTime", GeneralUtil_rice.gLastBootTime())
                put("rootJailbreak", HardwareUtil_rice.getIsRoot())
                put("keyboard", HardwareUtil_rice.gKeyboard(context))
                put("isSimulator", HardwareUtil_rice.gIsSimulator())
                put("dbm", HardwareUtil_rice.gMobileDbm(context)) //
                put("phoneNumber", "")
            }
            Gson().toJson(data).trim().gzipString()

        } catch (e: java.lang.Exception) {
            null
        }
    }
}